package com.groupbuying.pushordermsg.comsumer;

import com.groupbuying.pushordermsg.push.model.PushPayload;
import com.groupbuying.pushordermsg.util.JsonUtils;
import com.groupbuying.pushordermsg.util.PushUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.Map;

//@Component
public class MessageReceiver {
    protected static final Logger LOG = LoggerFactory.getLogger(PushUtils.class);

    @Autowired
    private PushUtils pushUtils;

    /**
     * 接收消息的方法
     */
    public void receiveMessage(String message) {
;
        LOG.info("收到一条待推送消息 - " + message);

        Map<String,Object> pushMap = JsonUtils.jsonToPojo(message, HashMap.class);
        String storeinfo = pushMap.get("storeUuid").toString();
        String orderamount = pushMap.get("payPrice").toString();


        //组装配置消息内容
        PushPayload payload = pushUtils.buildPushObject_all_alias_alert(storeinfo, orderamount);
        //极光推送消息
        pushUtils.JPushMsg(payload);


    }

}